-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimization wollok game #328
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #328 +/- ##
==========================================
+ Coverage 89.69% 89.76% +0.06%
==========================================
Files 28 28
Lines 3183 3204 +21
Branches 579 582 +3
==========================================
+ Hits 2855 2876 +21
Misses 172 172
Partials 156 156 ☔ View full report in Codecov by Sentry. |
test/benchmarks.ts
Outdated
const deltaError = Math.max(0.1, expectedTime * 0.1) // 0.1 or 10 % | ||
restore() | ||
|
||
// console.info(`${message} - ${fqn} - ${time} ms (${iterations} iterations)`) | ||
results.push({ message, fqn, time, iterations }) | ||
time.should.be.closeTo(expectedTime, deltaError) | ||
}) | ||
} | ||
|
||
benchmark('empty', 0.55) | ||
benchmark('visuals_1', 0.4) | ||
benchmark('visuals_100', 0.3) | ||
benchmark('ticks_1', 0.8) | ||
benchmark('ticks_100', 44) | ||
benchmark('onCollide_1', 0.8) | ||
benchmark('onCollide_100', 44) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these assertions portable on different machines / browsers / JS implementations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just hope:
- to have some number more or less regular in the CI
- detect when the number changes a lot
1b55a35
to
db4e5ed
Compare
"wollokVersion": ":master", | ||
"wollokVersion": ":optimization-wollok-game", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
benchmark('ticks_1', 12) | ||
benchmark('ticks_100', 637) | ||
benchmark('onCollide_1', 11) | ||
benchmark('onCollide_10_same_position', 5000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Este caso se debería poder optimizar reutilizando la lista de colliders:
- Sabiendo que si un collider choca con otro, el otro también choca con él
- Ahora se está iterando todos los visuales por cada uno, pero en este ejemplo termina armando siempre la misma lista de colliders
Ahora es medio paja hacerlo porque cada colisión es independiente del resto, habría que cambiar el modelo actual para centralizar el manejo de los colliders. Prefiero hacerlo en la próxima iteración.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Te dejo una pregunta, mañana si querés lo vemos
stub(console) | ||
const iterations = 30 | ||
|
||
const program = `games.${fqn}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
una pavada, pero no falta subir los programas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Están en Language
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Increibleee, Wollok vuelaa
[Run benchmarks]
^- esto hace que corran los benchmarks en el CI y ponga los resultados como comment del commit
Acá se mejora la performance de las natives críticas de Wollok Game en base a lo que había investigado @mind-ar en un PR/issue que no encontré.
La optimización que se implementa es evitar invocar los getters creados por properties en las natives de game (que, además, por querer optimizar de más tenía un bug).
Lo importante es que armé unos mini-benchmarks de game para medir esto.
De paso también abrí al puerta para poder compilar implementaciones nativas de cualquier método. Por ahora solo se hace para las properties (no solo de game, sino de todo el programa).
Quiero implementar más benchmarks del lenguaje antes de meterme con un compilador...
TODOs
Benchmarks en uqbar-project/wollok-language#236